package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TWardMapper;
import com.ruoyi.system.domain.TWard;
import com.ruoyi.system.service.ITWardService;
import com.ruoyi.common.core.text.Convert;

/**
 * 病房信息Service业务层处理
 * 
 * @author 杨一迪
 * @date 2024-12-28
 */
@Service
public class TWardServiceImpl extends ServiceImpl<TWardMapper,TWard> implements ITWardService

{
    @Autowired
    private TWardMapper tWardMapper;

    /**
     * 查询病房信息
     * 
     * @param id 病房信息主键
     * @return 病房信息
     */
    @Override
    public TWard selectTWardById(Long id)
    {
        return tWardMapper.selectTWardById(id);
    }

    /**
     * 查询病房信息列表
     * 
     * @param tWard 病房信息
     * @return 病房信息
     */
    @Override
    public List<TWard> selectTWardList(TWard tWard)
    {
        return tWardMapper.selectTWardList(tWard);
    }

    /**
     * 新增病房信息
     * 
     * @param tWard 病房信息
     * @return 结果
     */
    @Override
    public int insertTWard(TWard tWard)
    {
        tWard.setCreateTime(DateUtils.getNowDate());
        return tWardMapper.insertTWard(tWard);
    }

    /**
     * 修改病房信息
     * 
     * @param tWard 病房信息
     * @return 结果
     */
    @Override
    public int updateTWard(TWard tWard)
    {
        tWard.setUpdateTime(DateUtils.getNowDate());
        return tWardMapper.updateTWard(tWard);
    }

    /**
     * 批量删除病房信息
     * 
     * @param ids 需要删除的病房信息主键
     * @return 结果
     */
    @Override
    public int deleteTWardByIds(String ids)
    {
        return tWardMapper.deleteTWardByIds(Convert.toStrArray(ids));
    }

    /**
     * 批量软删除病房信息
     *
     * @param ids 需要软删除的病房信息主键
     * @return 结果
     */
    @Override
    public int softDeleteTWardByIds(String ids)
    {
        String[] strArray = Convert.toStrArray(ids);
        int count = 0;
        for (String s : strArray) {
            TWard tWard = tWardMapper.selectTWardById(Long.valueOf(s));
            tWard.setIsDelete(1);
            int i = tWardMapper.updateTWard(tWard);
            count = count + i;
        }
        return count;
    }
    @Override
    public List<TWard> selectTWardListByDeptId(Long deptId) {
        return tWardMapper.selectTWardListByDeptId(deptId);
    }

    /**
     * 删除病房信息信息
     * 
     * @param id 病房信息主键
     * @return 结果
     */
    @Override
    public int deleteTWardById(Long id)
    {
        return tWardMapper.deleteTWardById(id);
    }
}
